unit mFeature;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  System.Win.ScktComp, mcCommands;

type CFeature = class
  Constructor Create(sock: TCustomWinSocket);

  protected
  sock_: TCustomWinSocket;

  procedure sendfile(filename: string);
  procedure sendstring(dastring: string);

  //UTILITY FUNCTIONS
  function GetTempDir: string;
  function GetSysDir: string;
  function GetCurrentUser: string;
end;

implementation

procedure CFeature.sendfile(filename: string);
var
   thefile: file;
   filesize, bytesRead: DWORD;
   com: RCommand;

begin
    {
    hFile := CreateFile(PWideChar(filename), GENERIC_READ, 0, nil, OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL, 0);

      filesize := GetFileSize(hFile, nil);

      GetMem(buffer, filesize + 1);
      ZeroMemory(buffer, filesize + 1);

      ReadFile(hFile, buffer[1], filesize, bytesRead, nil);

      sock_.Socket.SendBuf(buffer[1], filesize + 1);


  CloseHandle(hFile);   }
  AssignFile(thefile, filename);
  filesize := 1;//filesize(thefile);
  CloseFile(thefile);

  com.magic := MAGIC_DWORD;
  com.command := COM_FILE_CLI;
  com.data := filesize;
  com.checksum := Random(CHECKSUM_RAND);

  sock_.SendBuf(com, SizeOf(com));



end;

procedure CFeature.sendstring(dastring: string);
begin

end;

Constructor CFeature.create(sock: TCustomWinSocket);
begin
  sock_ := sock;
end;

function CFeature.GetTempDir: string;
var
  Dir: string;
  Len: DWord;
begin
  SetLength(Dir,MAX_PATH);
  Len:=GetTempPath(MAX_PATH, PChar(Dir));
  if Len>0 then
  begin
    SetLength(Dir,Len);
    Result:=Dir;
  end;
end;

function CFeature.GetSysDir: string;
begin;

end;

function CFeature.GetCurrentUser: string;
begin;

end;



end.
